package cn.wolfcode.wolf2w.destination.controller;


import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.destination.entity.TaDestination;
import cn.wolfcode.wolf2w.destination.entity.TaRegion;
import cn.wolfcode.wolf2w.destination.query.DestinationQuery;
import cn.wolfcode.wolf2w.destination.service.ITaDestinationService;
import cn.wolfcode.wolf2w.destination.service.ITaRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 目的地表 前端控制器
 * </p>
 *
 * @author libai
 * @since 2024-07-23
 */
@RestController
@RequestMapping("/destinations")
public class TaDestinationController {

    @Autowired
    ITaRegionService regionService;
    @Autowired
    ITaDestinationService destinationService;

    /**
     *  热门区域
     * @param ishot
     * @return
     */
    @GetMapping("/regions")
    public R<List<TaRegion>> regions(int ishot){
      List<TaRegion>  list = regionService.queryByState(ishot);
      return R.ok(list);
    }

    /**
     * 热门目的地搜索
     * @param regionId
     * @return
     */
    @GetMapping("/search")
    public R<List<TaDestination>> search(Long regionId){
        /**
         * 如果传参是-1的话,将会显示全国地区
         */
      List<TaDestination>  list = destinationService.search(regionId);
      return R.ok(list);
    }
    /**
     * 当前目的地介绍位置  (吐司) (导航栏下面)
     * @param destId 目的地id
     * @return
     */
    @GetMapping("/toasts")
    public Object toasts(Long destId){
        List<TaDestination>  list = destinationService.queryToastsByDestId(destId);
        return R.ok(list);
    }

    /**
     * 写游记-所有目的地
     * @return
     */
    @GetMapping("/list")
    public R<List<TaDestination>> list(DestinationQuery qo){
        List<TaDestination> list = destinationService.listAll(qo);
        return R.ok(list);
    }



    //feign
    @GetMapping("/getById/{id}")
    public R<TaDestination> getById(@PathVariable("id") Long id) {
         TaDestination destination = destinationService.getById(id);
        return R.ok(destination);
    }

    /**
     * 目的地列表
     * @return
     */
    @GetMapping("/feign/list")
    public R<List<TaDestination>> feignList() {
        return R.ok(destinationService.list());
    }


}

